package com.zy.eb.web;

import com.zy.eb.model.EbProduct;
import com.zy.eb.model.EbProductCategory;
import com.zy.eb.service.EbProductCategorySercie;
import com.zy.eb.service.EbProductService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.List;
import java.util.Map;

/**
 * @Description: 用一句话描述
 * @Auther: 新梦想*陈超
 * @Date: 2020-12-09 08:14
 */
@Controller//迎宾证
@RequestMapping("/product")
public class EbProductController {

    @Autowired
    private EbProductService ebProductService;

    @Autowired
    private EbProductCategorySercie ebProductCategorySercie;

    @RequestMapping("/detail")
    public String detail(Model model, Integer epId){
        System.out.println("=====浏览器点击了某个商品======:epId=="+epId);
        //1.调用service查询该商品的详细信息
        EbProduct productDetail = ebProductService.detail(epId);
        //1.1.调用service层查询商品分类信息
        Map<String, List<EbProductCategory>> categoryMap = ebProductCategorySercie.selectBigAndSmallCate();
        //2.把数据绑定到model
        model.addAttribute("detail",productDetail);
        //2.1 将商品分类进行绑定
        model.addAttribute("categoryMap",categoryMap);
        //3.返回视图名称
        return "product-view";//templates/product-view.html
    }

}











